package top.zhangjianyong.tools.service.mybatis.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import top.zhangjianyong.tools.entity.BillFile;
import top.zhangjianyong.tools.mapper.BillFileMapper;
import top.zhangjianyong.tools.service.mybatis.IBillFileService;

import java.util.List;

/**
 * @author ： zhangjianyong
 * @date ： 2022/7/17 1:27 PM
 */
@Service
public class IBillFileServiceImpl
        extends ServiceImpl<BillFileMapper, BillFile>
        implements IBillFileService {


    @Override
    public List<BillFile> list(Long userId) {
        return lambdaQuery().eq(BillFile::getCreateBy, userId)
                .eq(BillFile::getDelFlag, 0)
                .orderByDesc(BillFile::getCreateTime)
                .list();
    }

    @Override
    public List<BillFile> list(Long userId, String state) {
        return lambdaQuery().eq(BillFile::getCreateBy, userId)
                .eq(BillFile::getState,state)
                .eq(BillFile::getDelFlag, 0)
                .list();
    }

    @Override
    public boolean del(Long billFileId) {
        return lambdaUpdate().eq(BillFile::getId, billFileId)
                .set(BillFile::getDelFlag, 1)
                .update();
    }
}
